<template>
	<view>
		<view class="box_bg"
			:style="'background: url('+ c_imgPath + 'indexBg.png'+ ') repeat-y 0 0 / 100% auto;'">
			
		</view>
		<mescroll-body ref="mescrollRef" class="valbox" @init="mescrollInit" :down="downOption" @down="downCallback"
			@up="upCallback">
			<view class="head_top">
				<view class="status_bar" :style="'height:'+ statusBarHeight +'px;'"></view>
				<view class="header_title">
					<view>
						<!-- @click="back()" <image :src="z_imgPath + 'back.png'"></image>返回 -->
					</view>
					<view class="hang1">无限赏 </view>
				</view>
			</view>
			<view class="qiehuan_box"> 
				<view class="qiehuan">
					<view @click="getlist(v)" v-for="(v,i) in arr" :key="i">
						<view :class="show==v?'xzs':'wzs'">{{v}}</view>
						<view class="qiehuan_img">
							<image v-if="show==v" :src="c_imgPath+'qiehuan.png'"></image>
						</view>
					</view>
				</view>
				<view class="qiehuan_box_right" @click="$refs.shuoming.open()">
					<image :src="c_imgPath + 'fhxz.png'"></image>
					<text>购买说明</text>
				</view>
			</view>
		
			<view class="qbt_con">
				<view v-for="(item,index) in listdata" :key="index" class="qbt_con_item" @click="todetails(item)"
					:style="'background: url('+ c_imgPath + 'kuang_bg.gif?1'+ ') no-repeat 0 0 / 100% 100%;'">
					<view class="item_title">{{item.title}}</view>
					<view class="item_img">
						<image :src="item.imgurl"></image>
						<view class="item_img_coupon" v-if="item.is_coupon == 2">
							<image :src="cc_imgPath + 'mine/coupon_img2.png'"></image>
						</view>
					</view>
					<view class="item_info"
						:style="'background: url('+ c_imgPath + 'kuang_bg_bom.png'+ ') no-repeat 0 0 / 100% 100%;'">
						<!-- <view class="item_info_left">{{item.sale_stock}}/{{item.stock}}</view> -->
						<!-- <view class="item_info_img">
							<image :src="c_imgPath+'box.png'"></image>
						</view> -->
						<view class="item_info_text">{{item.join_count}}次参与</view>
						<view class="item_info_price">￥<text>{{item.price}}</text></view>
					</view>
				</view>
			</view>
		</mescroll-body>
		<!-- 购买说明 -->
		<uni-popup ref="shuoming" type="center">
			<view class="pop" :style="'background: url('+ c_imgPath + 'gz_bg.png'+ ') no-repeat 0 0 / 100% 100%;'">
				<view class="pop_title">购买说明</view>
				<view class="pop_con">
					<scroll-view scroll-y="true" style="height: 440rpx;">
						<view v-html="news"></view>
					</scroll-view>
				</view>
			</view>
			<view class="shuoming_close" @click="$refs.shuoming.close()">
				<image :src="cc_imgPath + 'detail/close.png'"></image>
			</view>
		</uni-popup>
		<!-- 自定义底部 -->
		<!-- <tabbar :type="2"></tabbar> -->
	</view>
</template>

<script>
	import tabbar from '@/components/tabbar/tabbar.vue'
	export default {
		components: {
			tabbar
		},
		data(){
			return{
				c_imgPath: 'https://qt.yhemall.com/shouye/',
				cc_imgPath: 'https://qt.yhemall.com/',
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				arr: ['无限赏','宝藏令'],
				listdata: [],
				downOption: {
					auto: false
				},
				show: '无限赏',
				keyword: '',
				news:'',
				token:''
			}
		},
		onShow() {
			this.token = uni.getStorageSync('token');
		},
		onLoad() {
			//购买说明
			this.getDanye(4)
		},
		methods: {
			//购买说明
			getDanye(e) {
				let that = this;
				that.req({
					url: 'danye',
					data: {
						type: e
					},
					success(res) {
						if (res.status == 1) {
							that.news = res.data
						}
					}
				})
			},
			todetails(e) {
				// 无限赏
				if (e.type == 2) {
					uni.navigateTo({
						url: '/pages/shouye/detail_wuxian?goods_id=' + e.id
					})
				} else {
					uni.navigateTo({
						url: '/pages/shouye/detail?goods_id=' + e.id
					})
				}
			
			},
			getlist(v) {
				if(v == '无线赏'){
					this.getDanye(4)
				}else{
					uni.navigateTo({
						url:'/pages/shouye/wxl'
					})
					return
				}
				this.show = v;
				// this.listdata = []
				// this.mescroll.resetUpScroll()
				this.loadData(1)
			},
			/*下拉刷新的回调 */
			downCallback() {
				// this.mescroll.resetUpScroll()
				this.loadData(1)
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				this.loadData(page.num);
			},
			loadData(pageNo) {
				// 模拟接口
				let that = this;
				that.req({
					url: 'goods',
					data: {
						page: pageNo,
						type: 2,
						keyword: that.keyword,
						is_show:1,
						user_id:uni.getStorageSync('userinfo').ID?uni.getStorageSync('userinfo').ID:''
					},
					success: function(res) {
						that.mescroll.endByPage(res.data.data.length, res.data.data.last_page);
						if (pageNo == 1) {
							that.listdata = res.data.data;
						} else {
							that.listdata = that.listdata.concat(res.data.data);
						}
						console.log(that.listdata)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.header_title {
		height: 70rpx;
		line-height: 70rpx;
		width: 100%;
		text-align: center;
		box-sizing: border-box;
		font-weight: bold;
		display: flex;
		align-items: center;
		padding-left: 30rpx;
		box-sizing: border-box;
		font-size: 32rpx;
		color: #ffffff;
	}
	
	.status_bar {
		height: var(--status-bar-height);
		width: 100%;
	}
	
	.head_top {
		/* #ifndef MP */
		margin-top: 44rpx;
		/* #endif */
	}
	.header_title>view:nth-of-type(2) {
		width: 100%;
		/* margin: auto; */
	}
	
	
	.qiehuan_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 20rpx;
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		color: #FFFFFF;
		font-size: 24rpx;
	}
	.qiehuan_box_right{
		display: flex;
		align-items: center;
		image{
			width: 30rpx;
			height: 30rpx;
		}
		text{
			line-height: 30rpx;
			margin-left: 10rpx;
		}
	}
	.qiehuan_box>image {
		width: 30rpx;
		height: 30rpx;
	}
	
	.qiehuan {
		display: flex;
		justify-content: space-around;
		width: 300rpx;
		font-weight: bold;
		font-family: YouSheBiaoTiHei;
		.qiehuan_img{
			height: 24rpx;
			image{
				width: 94rpx;
				height: 24rpx;
			}
		}
	}
	
	.qiehuan>view {
		flex: 1;
		text-align: center;
	}
	
	.wzs {
		font-size: 28rpx;
		color: #9E99E3;
	}
	
	.xzs {
		font-size: 32rpx;
		background: linear-gradient(0deg, #B75AFF 0%, #E7CBFF 100%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
	}
	
	
	
	.qbt_con {
		margin: 0rpx auto;
		width: 710rpx;
		padding-bottom: 100rpx;
		// display: flex;
		// justify-content: space-between;
		// flex-wrap: wrap;
		font-size: 24rpx;
	}
	
	.qbt_con_item {
		margin-top: 30rpx;
		border-radius: 20rpx 20rpx 0 0;
		width:100%;
		height: 400rpx;
		position: relative;
		padding: 0rpx 20rpx ;
		box-sizing: border-box;
		.item_title{
			width: 450rpx;
			color: #FFFFFF;
			font-size: 24rpx;
			font-weight: 400;
			line-height: 50rpx;
			margin-left: 30rpx;
			font-family: SourceHanSansSC;
			overflow:hidden;  
			text-overflow:ellipsis;
			white-space:nowrap;
		}
		.item_img{
			text-align: center;
			image{
				width: 100%;
				height: 300rpx;
			}
			.item_img_coupon{
				position: absolute;
				bottom: 70rpx;
				right: -20rpx;
				image{
					width: 160rpx;
					height: 120rpx;
				}
			}
		}
		.item_info{
			color: #FFFFFF;
			display: flex;
			align-items: center;
			height: 70rpx;
			margin-top: -10rpx;
			position: absolute;
			bottom: 20rpx;
			left: 2%;
			width: 96%;
			image{
				width: 30rpx;
				height: 30rpx;
			}
			.item_info_left{
				font-size: 24rpx;
				margin-left: 30rpx;
				margin-top: 10rpx;
			}
			.item_info_img{
				display: flex;
				align-items: center;
				margin-top: 10rpx;
				image{
					width: 22rpx;
					height: 24rpx;
					margin-left: 10rpx;
				}
			}
			.item_info_text{
				margin-left: 30rpx;
				margin-top: 10rpx;
				flex: 1;
			}
			.item_info_price{
				font-size: 24rpx;
				margin-right: 25rpx;
				width: 120rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				text{
					font-size: 32rpx;
				}
			}
		}
	}
	
	.list_1 {
		width: 290rpx;
		height: 290rpx;
		border-radius: 10rpx 10rpx 0rpx 0rpx;
		/* position: relative; */
		display: flex;
		align-items: center;
		justify-content: center;
		overflow: hidden;
	}
	
	.list_1>image {
		width: 290rpx;
		height: 290rpx;
		/* position: absolute; */
		border-radius: 10rpx 10rpx 0 0;
		/* margin-left: 4rpx; */
		margin-top: 5rpx;
	}
	
	.list_2 {
		padding: 20rpx 0;
		border-radius: 0rpx 0rpx 10rpx 10rpx;
		color: #FFFFFF;
	}
	
	
	.qbt_con_item_3 {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 4rpx;
		color: #C95C10;
	}
	
	.qbt_con_item_price {
		color: #FFFFFF;
		margin-left: 20rpx;
		opacity: .4;
		display: flex;
		align-items: center;
	}
	
	.qbt_con_item_price>image {
		width: 30rpx;
		height: 30rpx;
		margin-left: 10rpx;
	}
	
	.redu {
		width: 290rpx;
		height: 46rpx;
		margin-top: 10rpx;
		display: flex;
		align-items: center;
	}
	
	.redu>image {
		width: 32rpx;
		height: 32rpx;
		border: 2rpx solid rgba(255, 255, 255, 0.8);
		border-radius: 50%;
	}
	
	
	.pop_btn {
		width: 484rpx;
		height: 68rpx;
		background: #000000;
		border: 1px solid #2FB4FF;
		border-radius: 6rpx;
		font-size: 32rpx;
		color: #2FB4FF;
		margin: 50rpx auto 0;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	
	
	.pop_con {
		height: 440rpx;
		margin: auto;
		padding: 0rpx 36rpx;
		font-size: 24rpx;
		line-height: 36rpx;
		color: #FFFFFF;
		box-sizing: border-box;
		overflow-y: scroll;
	}
	
	.pop_title {
		/* font-family: 'zcq'; */
		font-size: 40rpx;
		color: #96FFFE;
		height: 128rpx;
		line-height: 128rpx;
		text-align: center;
	}
	
	.pop {
		width: 543rpx;
		height: 801rpx;
		box-sizing: border-box;
		/* background: #FFFFFF; */
		/* border-radius: 20rpx; */
		.pop_title{
			font-size: 32rpx;
			font-weight: bold;
			font-family: Source Han Sans CN;
			padding-top: 50rpx;
			background: linear-gradient(0deg, #A98FD3 0%, #E7CBFF 50%);
			-webkit-background-clip: text;
			-webkit-text-fill-color: transparent;
		}
	}
</style>
